<?php
//Page-Level Plugin CSS - Tables
echo $this->Html->css('plugins/dataTables/dataTables.bootstrap');
//Table
echo $this->Html->script('plugins/dataTables/jquery.dataTables');
echo $this->Html->script('plugins/dataTables/dataTables.bootstrap');
?>

<div class="mainBox">
	<div class="col-lg-12">
		<h2 class="page-header"><?php echo $title_for_layout?></h2>
	</div>
	<div class="searchBox">
	<?php
	echo $this->Form->create('category', array('type' => 'get'));
	echo $this->Form->input('cat_type', array(
			'options' => $category_type,
			'empty' => '--Choose category--',
			'label' => false,
			'div' => false,
			'class' => 'form-control',
	));
	echo $this->Form->submit('Search',array(
			'class' => 'btn btn-primary',
			'id' => 'ProductFilter',
			'title' => 'Search',
			'label' => false,
			'div' => false
		));

	echo $this->Form->end();
	?>
	</div>
</div><!-- /.mainBox -->

<div id="mainTable">
	<table class="table table-striped table-bordered table-hover" id="dataTables-example">
		<thead>
			<tr>
				<th style="text-align:center">STT</th>
				<th>Tên danh mục</th>
				<th width="10%">Hiển thị trang chủ</th>
				<th style="text-align:center"><img alt="sửa" src="<?php echo $this->webroot ?>img/edit.png" class="image"></th>
				<th style="text-align:center"><img alt="Xóa" src="<?php echo $this->webroot ?>img/delete.gif" class="image"></th>
			</tr>
		</thead>
		<tbody>
			<?php if ($this->Paginator->param('count') > 0) :?>
				<?php
				//$countno = ($this->Paginator->current($model = null) - 1) * $page_number_limit;
				$cat_type = "";
				$countno = 0;
				foreach ($datas as $cat):
					$countno ++;
					/*
					if($cat_type != $cat["cat_type"]):
						$cat_type = $cat["cat_type"];
					?>
					<tr>
							<td align="center" colspan="4"><strong><?php echo $category_type[$cat_type];?></strong></td>
						</tr>

					<?php
					endif;
					*/
				?>
				<tr <?php echo $changeBgTr; ?>>
					<td align="center"><?php echo $countno;?></td>
					<td>
						<?php
						for($j=0; $j < $cat["level"]; $j++) echo "---";
						echo $cat['cat_name']
						?>
					</td>
					<td align="center">
						<?php
							$checked = 0;
							if ($cat['cat_home'] == 1) {
								$checked = 1;
							}
						?>
						<a class="news_update_hot" href="<?php echo $this->Html->url(array('controller' => 'categorys', 'action' => 'update', $cat['id'], 'cat_home')) ?>" title="Active or Inactive" rel="tooltip">
							<?php echo $this->Html->image("check_$checked.gif", array("alt" => "", 'class' => 'image_hot', 'value' => abs($cat['cat_home'] - 1)));?>
						</a>
					</td>
					<td align="center"><a href="<?php echo $this->Html->url(array('controller' => 'categorys', 'action' => 'edit', $cat['id'])) ?>"><?php echo $this->Html->image("edit.png", array("alt" => "sửa", 'class' => 'image'));?></a></td>
					<td align="center">
					<?php
						echo $this->Form->postLink(
							'Delete',
							array('controller' => 'categorys', 'action' => 'delete', $cat['id']), null, __('Are you sure you want to delete ?', $cat['id'])
						);
					?>
					</td>

				</tr>
				<?php endforeach;?>
			<?php endif;?>
		</tbody>
	</table>
	<?php
	/*
	<div class="row">
		<div class="col-sm-6">
			<div class="dataTables_info" id="dataTables-example_info" >Showing <?php echo $start;?> to <?php echo $end;?> of <?php echo $this->Paginator->param('count');?> entries</div>
		</div>
		<div class="col-sm-6">
			<div id="dataTables-example_paginate" class="dataTables_paginate paging_simple_numbers">
				<ul class="pagination flRight box25">
				<?php
				if($this->Paginator->param('count') > $page_number_limit):
					echo $this->Paginator->prev(__('previous'), array(
						'class' => 'previous',
						'tag' => 'li',
						'disabledTag' => 'a'
					));

					echo $this->Paginator->numbers(array(
						'separator' => '    ',
						'tag' => 'li',
						'currentClass' => 'active',
						'currentTag' => 'a'
					));

					echo $this->Paginator->next(__('next'), array(
						'class' => 'next',
						'tag' => 'li',
						'disabledTag' =>'a'
					));
				endif;
				?>
				</ul><!-- /.pagination -->
			</div>
		</div>
	</div>
	*/
	?>

</div>
<?php //echo $this->element('sql_dump'); ?>